package com.example.hostsys.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Data;
import lombok.Getter;
import lombok.Setter;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.authority.SimpleGrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import javax.persistence.*;
import java.util.ArrayList;
import java.util.Collection;
import java.util.LinkedList;
import java.util.List;

@Getter
@Setter
@Entity
@JsonIgnoreProperties(value = {"user","houses","hibernateLazyInitializer"})
public class HostMan {
    @Id
    private Integer id;
    private String phone;
    private String address;
    @OneToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "user_id",nullable = false,unique = true)
    private User user;

    @OneToMany(mappedBy = "hostMan",fetch = FetchType.LAZY)
    private List<House> houses;

    @Override
    public String toString() {
        return "HostMan{" +
                "id=" + id +
                ", phone='" + phone + '\'' +
                ", address='" + address + '\'' +
//                ", user=" + user +
//                ", houses=" + houses +
                '}';
    }
}
